<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .layui-table-cell{white-space: nowrap!important;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年度：</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">委托方</label>
                        <div class="layui-input-block">
                            <input type="text" name="weier" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">资质类型</label>
                        <div class="layui-input-block">
                            <div id="bidtype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">所在地</label>
                        <div class="layui-input-block">
                            <input type="text" name="areas" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>


                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="touer_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目类别：</label>
                        <div class="layui-input-block">
                            <select id="entype" name="entype" lay-filter="entype">
                                <option value="">请选择</option>
                                <option value="1">中标项目</option>
                                <option value="2">陪标项目</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    var currentYear = new Date().getFullYear();
    var param_year = getQueryVariable('year') || '';
    if(param_year != ''){
        currentYear = param_year
    }

    $("#year").val(currentYear);

    var colsShang = [];
    var colsXia = [];

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });
        colsShang.push( {type:'numbers',title:'序号',totalRowText: '合计',rowspan:2} );
        colsShang.push( {field: 'number', title: '项目编号',merge:['name'],rowspan:2} );
        colsShang.push( {field:'name',title:'项目名称',merge:['name'],rowspan:2,templet: function(d){return '<span class="colorlan" onclick="openPage(\'../bid/show.php?id='+d.id+'\')">'+d.name+'</span>';}} );
        colsShang.push( {field: 'entype_name', title: '项目类别',merge:['name'],rowspan:2} );
        colsShang.push( {field: 'bidtype_name', title: '资质类型',merge:['name'],rowspan:2} );
        colsShang.push( {field: 'kaidt', title: '开标时间',merge:['name'],rowspan:2} );
        colsShang.push( {field: 'state_name', title: '项目状态',merge:['name'],rowspan:2} );
        colsShang.push( {field: 'weier', title: '委托方',merge:['name'],rowspan:2} );
        colsShang.push( {field: 'touunit', title: '投标单位',rowspan:2} );
        colsShang.push( {field: 'touxing_name', title: '性质',rowspan:2} );



        facade.ajax({url: ask_bid_fei_dai_lan_list, data:{seatype:'col'}}).done(function(res){
            if (res.code === 2000) {

                var feicolarr = res.data.feicolarr;
                for (var mmm in feicolarr) {
                    colsShang.push({field: '', title: feicolarr[mmm].title,colspan:4,align:'center'});
                    colsXia.push({field: 'ying_'+feicolarr[mmm].value, title: '应收',totalRow: true});
                    if(feicolarr[mmm].value == 'xiaoji'){
                        colsXia.push({field: 'shou_'+feicolarr[mmm].value, title: '收入 A',totalRow: true});
                    }else{
                        colsXia.push({field: 'shou_'+feicolarr[mmm].value, title: '收入',totalRow: true});
                    }
                    colsXia.push({field: 'dai_'+feicolarr[mmm].value, title: '待收'});
                    if(feicolarr[mmm].value == 'xiaoji'){
                        colsXia.push({field: 'zhi_'+feicolarr[mmm].value, title: '支出 B',totalRow: true});
                    }else{
                        colsXia.push({field: 'zhi_'+feicolarr[mmm].value, title: '支出',totalRow: true});
                    }
                }

                colsShang.push( {field: '', title: '投标保证金',colspan:3,align:'center'} );
                colsXia.push( {field: 'baoshou', title: '收取 C',totalRow: true} );
                colsXia.push( {field: 'baofan', title: '返还 D',totalRow: true} );
                colsXia.push( {field: 'koufee', title: '扣收 E',totalRow: true} );
                colsShang.push( {field: 'yingyu', title: '盈余 (A-B)+(C-D-E)',rowspan:2,totalRow: true} );


                var mytable = table.render({
                    elem: "#datalist",id: "datalist"
                    ,url: facade.url(ask_bid_fei_dai_lan_list),where: {year:currentYear}, page: false, height: 'full-140'
                    ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
                    ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
                    ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                    ,text: TabInit.text,totalRow: true
                    ,parseData: function (res) {


                        var year_str = '<option value="">请选择</option>';
                        var year = res.data.year;
                        for (var key in year){
                            if(res.data.is_year == year[key]){
                                year_str += '<option value="'+year[key]+'" selected>'+year[key]+'</option>';
                            }else {
                                year_str += '<option value="'+year[key]+'">'+year[key]+'</option>';
                            }

                        }
                        $("#year").html(year_str);

                        var state_str = '<option value="">请选择</option>';
                        var state = res.data.state;
                        for (var key in state){
                            if(res.data.is_state == key){
                                state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                            }else {
                                state_str += '<option value="'+key+'">'+state[key]+'</option>';
                            }

                        }
                        $("#state").html(state_str);


                        xmselect_dan('bidtype', res.data.bidtype, res.data.is_bidtype, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('zhaotype', res.data.zhaotype, res.data.is_zhaotype, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })


                        render_from();
                        return {
                            "code": res.code,
                            "msg": res.message,
                            "count": res.data.total,
                            "data": res.data.data
                        };
                    }
                    , cols: [
                        colsShang
                    ,
                        colsXia
                    ]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });

            }
        });

        listTableSearch(form, table);
    });

    function auth_but_func_show(){
        openPage('dai.php');
    }

</script>
</body>
</html>
